package BehaviorModel.iterorModel;

import java.util.Iterator;
import java.util.List;

public class InfoReserveIteror implements Iterator {

    List<Department> departments;

    private int indexOfIterator; // 当前迭代器位置

    public InfoReserveIteror(List<Department> departments) {
        this.departments = departments;
        this.indexOfIterator = departments.size() - 1;
    }

    public void setDepartments(List<Department> departments) {
        this.departments = departments;
        this.indexOfIterator = departments.size() - 1;
    }

    @Override
    public boolean hasNext() {
        if (indexOfIterator>=0){
            return true;
        }
        return false;
    }

    @Override
    public Object next() {
        if (hasNext()){
            return departments.get(indexOfIterator--);
        }
        return null;
    }

    /**
     * 功能描述: 默认为空实现
     */
    @Override
    public void remove() {

    }
}
